package com.chunxuan.langquan.base;


import com.chunxuan.langquan.dao.http.TokenInterCeptor;

import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;

public class Config {
    public static final boolean IS_DEBUG = true;

    public static final String URL = "https://langquan.17zhutui.com/";
//  public static final String URL_LS = "https://ydt.lstranger.cn/";
    public static final String URL_LS = "https://yunjianyan.ilicloud.cn/";
    public static final String URL_IMG = "https://yunjianyan.ilicloud.cn/uploads/";

    public static final String TIME_FORMATE = "yyyy-MM-dd HH:mm:ss";
    public static final String TIME_FORMATE_YMD = "yyyy-MM-dd";
    public static final String TIME_FORMATE_HMS = "HH:mm:ss";

    public static final String WX_APP_ID = "wxa69d4a8b2aad9f91";
    public static final String WX_APP_SECRET = "6a1621c293c1b79fa28e6fbfc370fb5d";

    public static final String QQ_APP_ID = "101933292";

    public static final String USER_PREF_KEY = "USER_PREF_KEY";
    public static final String PASSWORD_PREF_KEY = "PASSWORD_PREF_KEY";

    public static final String IS_SHOW = "IS_SHOW";

    public static final String MALL_SWITCH = "MALL_SWITCH";

    public static final String GLOBAL_HEADER = "GLOBAL_HEADER";

    public static final String PROVINCE = "PROVINCE";
    public static final String CITY = "CITY";
    public static final String AREA = "AREA";

    static OkHttpClient client;

    public static OkHttpClient getClient() {
        if (null == client) {
            client = new OkHttpClient.Builder()
//                    .addInterceptor(getHealthInterceptor())
                    .addInterceptor(getLoggingInterceptor())
                    .addInterceptor(new TokenInterCeptor())
                    .build();
        }
        return client;
    }

    static HttpLoggingInterceptor loggingInterceptor;

    public static HttpLoggingInterceptor getLoggingInterceptor() {
        if (null == loggingInterceptor) {
            loggingInterceptor = new HttpLoggingInterceptor();
        }
        if (IS_DEBUG) {
            loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
        } else {
            loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.NONE);
        }
        return loggingInterceptor;
    }
}
